*Analysis on the determinants of individual decisions to abandon the mainstream Left (Section 4)
*Based on 40 country-elections

use cses2to4_40cases, clear

*-------------------------------------------------------------------------------
*0. Preparation of variables
*-------------------------------------------------------------------------------

run 02a3a_Recoding_Abandon.do


*-------------------------------------------------------------------------------
*1. Trade-off analysis with the dichotomoy workers vs non-workers (clas2fin)
*-------------------------------------------------------------------------------

*11_3level: party compet
xtmelogit switch_x i.unionm i.clas2fin c.age i.gender i.educ ib4.locat c.c_inratiopool1 c.c_crl c.c_crr c.c_cg /// 
if clas2fin!=. & unionm!=. & age!=. & gender!=.  & locat!=. & educ!=. /// 
|| cntry: || cntelec: clas2fin , cov(un) /*highest level comes first in the command (here country)*/
estat icc
estadd scalar icc=r(icc2)
estimates store m11_3level_40

*12_3level: + crisis*PMincumbency + govtparty
xtmelogit switch_x i.unionm i.clas2fin c.age i.gender i.educ ib4.locat c.c_inratiopool1 c.c_crl c.c_crr c.c_cg i.crisisinc i.govtparty /// 
if clas2fin!=. & unionm!=. & age!=. & gender!=.  & locat!=. & educ!=. /// 
|| cntry: || cntelec: clas2fin , cov(un) 
estat icc
estadd scalar icc=r(icc2)
estimates store m12_3level_40

*13_3level: + interaction class*class profile
xtmelogit switch_x i.unionm i.clas2fin c.age i.gender i.educ ib4.locat c.c_inratiopool1 c.c_crl c.c_crr c.c_cg i.crisisinc i.govtparty c.c_inratiopool1#i.clas2fin /// 
if clas2fin!=. & unionm!=. & age!=. & gender!=.  & locat!=. & educ!=. /// 
|| cntry: || cntelec: clas2fin , cov(un) 
estat icc
estadd scalar icc=r(icc2)
estimates store m13_3level_40

*Appendix 5
esttab m11_3level_40 m12_3level_40 m13_3level_40 using Output11.rtf, replace se aic (1) bic (1) scalars(icc ll df_m) sfmt(3 1 0) b(3) nobaselevels nogaps /// 
transform (ln*: exp(@)^2 exp(@)^2) star(+ 0.10 * 0.05 ** 0.01 *** 0.001) 

*Figure 1

set scheme s1mono

estimates restore m13_3level_40
quietly margins, dydx(clas2fin) at (c_inratiopool1=(-0.4(0.2)1)) level (95) predict(mu fixedonly) 
marginsplot, recast (line) yline(0) xsize (4.5) ysize (3.2)
graph save fig1a_3level_40, replace

estimates restore m13_3level_40
quietly margins clas2fin, at (c_inratiopool1=(-0.4(0.2)1)) predict(mu fixedonly)  
marginsplot, noci ysc(range(0.25 0.4)) ylabel(0.25 (0.05) 0.4) xsize (4.5) ysize (3.5)
graph save fig1b_3level_40, replace

